Coroutine builders like launch() have an optional start parameter. One value for that parameter is CoroutineStart.LAZY. This sets up the coroutine and returns the Job, but the coroutine is not moved into the active state. As a result, Kotlin and the underlying platform will not do the work represented by the Job.

If you run this sample, instead of seeing an additional message after the two-second wait, you only see the initial message. That is because the lambda expression supplied to launch() is not being executed, since the coroutine is lazy.

You can learn more about this in:
Tags:
Run Edit